package buttons;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import controller.TurtleController;

public class PlayButton
{
    JButton myButton;
    TextInput myText;
    TurtleController myController;

    public PlayButton(String s, TurtleController controller, TextInput text)
    {
        myButton = new JButton(s);
        myController = controller;
        myText = text;
        myButton.addActionListener(new ActionListener()
        {
            @Override
            public void actionPerformed(ActionEvent e)
            {
                /*
                 * TODO: If we actually implement this, do something here!
                 */
                myController.doAnimation();
                myController.parseAndEvaluate(myText.getText());
                myText.setText("");
                myController.undoAnimation();
            }
        });
    }

    public JButton getInstance()
    {
        return myButton;
    }
}
